package hust.rpc;

import hust.rpc.constants.Constants;
import hust.rpc.proxy.Proxy;
import hust.rpc.service.HelloService;
import hust.rpc.utils.SingletonUtils;
import hust.rpc.utils.ThreadUtils;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
public class ConsumerServer {

    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        ConsumerBootstrap.run(Constants.REGISTRY_HOST, Constants.REGISTRY_PORT);
        Proxy proxy = SingletonUtils.getInstance(Proxy.class);
        HelloService service = proxy.getProxy(HelloService.class);
        for (int i = 0; i < 1000; i++) {
            int finalI = i;
            ThreadUtils.execute(() -> {
                String result = service.compute(finalI, "SOBXiong");
                log.info(result);
            });
        }
    }
}
